Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove params from config and introduce app context #1774

Merged
merged 28 commits into from
Feb 27, 2024

Conversation

skosito
Copy link
Contributor

@skosito skosito commented Feb 19, 2024

Description

Main purpose of linked issue is to remove runtime params from config.
Simple split of these params and config resulted in one more argument being passed around from top level (called ZetaCoreContext). However, since config and these params are still related, it makes sense to have them together in top level struct (called AppContext).

I also added masterLogger to AppContext as illustration and proposal that these common application context specific things can be grouped together and passed around and accessible as needed in convenient way.

This is opened as draft PR to get some feedback on this solution and then will be converted in proper PR and tested.

Closes: #1608

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.

Still in draft phase.

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Checklist:

  • I have added unit tests that prove my fix feature works

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the global direction of sperating the runtime values into a context object and having a high level app context is good.

Would be great to have a look from @ws4charlie (he's on public holiday today)

cmd/zetaclientd/start.go Outdated Show resolved Hide resolved
zetaclient/app_context/app_context.go Outdated Show resolved Hide resolved
zetaclient/app_context/app_context.go Show resolved Hide resolved
zetaclient/app_context/app_context.go Outdated Show resolved Hide resolved
zetaclient/app_context/app_context.go Outdated Show resolved Hide resolved
zetaclient/bitcoin/bitcoin_client_rpc_test.go Outdated Show resolved Hide resolved
zetaclient/evm/evm_client.go Outdated Show resolved Hide resolved
zetaclient/zetabridge/tx.go Show resolved Hide resolved
@skosito
Copy link
Contributor Author

skosito commented Feb 19, 2024

@lumtis thanks for review, i fixed some comments, left some of bigger questions (such as using pointers and missing docs) to check further

this PR was more to get thoughts on overall approach, if you guys think its fine i will fine tune remaining details, let's also wait for @ws4charlie review though

Copy link
Contributor

@kevinssgh kevinssgh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some minor comments

zetaclient/core_context/zeta_core_context.go Outdated Show resolved Hide resolved
zetaclient/core_context/zeta_core_context.go Outdated Show resolved Hide resolved
cmd/zetaclientd/debug.go Outdated Show resolved Hide resolved
cmd/zetaclientd/start.go Outdated Show resolved Hide resolved
cmd/zetaclientd/start.go Outdated Show resolved Hide resolved
cmd/zetaclientd/start.go Outdated Show resolved Hide resolved
zetaclient/zetabridge/tx.go Outdated Show resolved Hide resolved
@lumtis
Copy link
Member

lumtis commented Feb 22, 2024

@skosito I see PR comments have been addressed, is it ready to be reviewed?

@skosito
Copy link
Contributor Author

skosito commented Feb 22, 2024

@skosito I see PR comments have been addressed, is it ready to be reviewed?

i was fixing smoke tests, just want to do a bit more testing, will convert to ready for review in couple of hours

@skosito skosito marked this pull request as ready for review February 22, 2024 11:40
Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Few suggestions about adding more comments.

@ws4charlie can you have a look today? I think it would be great to merge soon as it will have conflicts with the restricted addresses PR

changelog.md Outdated Show resolved Hide resolved
zetaclient/app_context/app_context.go Show resolved Hide resolved
zetaclient/app_context/app_context.go Show resolved Hide resolved
zetaclient/core_context/zeta_core_context.go Show resolved Hide resolved
zetaclient/core_context/zeta_core_context.go Show resolved Hide resolved
zetaclient/zetabridge/tx.go Show resolved Hide resolved
zetaclient/zetabridge/zetacore_bridge.go Show resolved Hide resolved
Copy link

codecov bot commented Feb 23, 2024

Codecov Report

Attention: Patch coverage is 0% with 38 lines in your changes are missing coverage. Please review.

Project coverage is 38.03%. Comparing base (3ba44a1) to head (5f48d63).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #1774   +/-   ##
========================================
  Coverage    38.03%   38.03%           
========================================
  Files          205      205           
  Lines        12526    12524    -2     
========================================
  Hits          4764     4764           
+ Misses        7374     7372    -2     
  Partials       388      388           
Files Coverage Δ
zetaclient/evm/inbounds.go 13.30% <0.00%> (ø)
zetaclient/tss/tss_signer.go 10.42% <0.00%> (ø)
zetaclient/zetabridge/zetacore_bridge.go 0.00% <0.00%> (ø)
zetaclient/bitcoin/bitcoin_client.go 13.28% <0.00%> (-0.07%) ⬇️
zetaclient/zetabridge/tx.go 0.00% <0.00%> (ø)
zetaclient/evm/evm_client.go 0.30% <0.00%> (+<0.01%) ⬆️
zetaclient/supplychecker/zeta_supply_checker.go 14.10% <0.00%> (ø)

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!

@skosito
Copy link
Contributor Author

skosito commented Feb 26, 2024

@lumtis @kingpinXD I opened up an issue on missing thins you mentioned on pointers and core context unit tests #1807, I can pick this issue up soon so it is addressed.

Using separate issue because this is leftover from previous solution and to keep this PR small and short lived. Please let me know if this is ok and not a blocker to merge this PR.

Copy link
Contributor

@ws4charlie ws4charlie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let a few minor comments

@skosito
Copy link
Contributor Author

skosito commented Feb 27, 2024

@ws4charlie could you please check PR again when you get a chance, I merged latest develop with your changes and fixed conflicts and addressed your comments

also, initially i put masterLogger in appContext, but i see you introduced clientLoggers in your PR, so I decided to keep it out of app context since it is not scope of this PR, and to not change your implementation - please let me know if you think it belongs to app context and we can create issue to return it, or do it in this PR

@skosito skosito merged commit cfd27a7 into develop Feb 27, 2024
19 of 20 checks passed
@skosito skosito deleted the refactor-remove-params-from-config branch February 27, 2024 19:53
@lumtis lumtis mentioned this pull request Mar 1, 2024
10 tasks
lumtis added a commit that referenced this pull request Mar 12, 2024
* simplify docker compose

* fix makefi;e

* add new version

* type

* fix restart client

* some fixes

* add light upgrade test

* fix gov sending

* add admin function test command

* performance test

* fix lint

* add pprof port

* some fixes in tests

* test: emissions unit test (#1767)

* ci: run build workflow on develop push for code coverage generation (#1793)

* refactor: zetaclient metrics (#1783)

* Refactor zetaclient metrics

* Fix blame counter init

* Add changelog entry

* Add unreleased to changelog

* Remove blank line

* feat: initiated feature of zetaclient-restricted-address (#1790)

* initiated feature of zetaclient-banned-address

* fix some issues in e2e tests

* fix gosec issues

* some unit tests, comments and refactor

* unified log prints for restricted address detection

* move restricted address to Unreleased section

* improved compliance log prints

* update compliance log print according to CharlieMc

* chore(codecov.yml): fix ignore extension (#1814)

* chore(codecov.yml): fix ignore extension

* changelog

* refactor: remove params from config and introduce app context (#1774)

* refactor(`crosschain`): move ballot voting logic into `observer` (#1511)

* move logic for ballot voting for inbound

* fix mocks

* goimports

* changelog

* fix unit tests

* fix CI =

* x/observer/keeper/vote_outbound.go x/crosschain/types/expected_keepers.go x/crosschain/keeper/msg_server_vote_outbound_tx.go

* update mocks

* refactor finalized check

* make generate

* initialize vote inbound tests

* add sdk keepers in observer testutil

* implement mock option for observer

* inbound vote test

* initialize outbound tests

* goimports

* vote outbound tests

* update changelog

* test with integration tests

* add isNew in vote_inbound

* add tests back

* use tmp context for ballot logic

* add new test for finalized ballot

* add not finzalized test

* remove unused comment

* fix bitcoin credentials

* change upgrade version

* fix performance tests

* handler

* fix setup handler

* add light flag and use it for upgrade tests

* fix username

* add performance test back

* Update cmd/zetae2e/local/ethereum.go

* stefan comments

* changelog

* fix

---------

Co-authored-by: Tanmay <[email protected]>
Co-authored-by: skosito <[email protected]>
Co-authored-by: Charlie Chen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove runtime values from config
5 participants